<?php
session_start();
include_once($_SERVER['DOCUMENT_ROOT']."/php_functions/database_connectie.php");

if(empty($_GET['team'])) {
	//Er is geen team geselecteerd
	$_SESSION['ingelogd'] = 12;
}else {
	//Verwijder alle session variabelen
	unset($_SESSION['spelerId']);
	unset($_SESSION['rechten']);
	unset($_SESSION['team']);
	
	$result = mysql_query("SELECT Team.team, Team.teamId FROM Team, Teaminstellingen WHERE Team.teamId = Teaminstellingen.teamId AND Teaminstellingen.seizoen = '".(date('Y'))."' AND Teaminstellingen.nietIngelogden > 0 AND Teaminstellingen.teamId = '".$_GET['team']."'");
	if($result <> null && mysql_num_rows($result) > 0) {
		$row = mysql_fetch_object($result);
		$_SESSION['team'] = $row->teamId;
		$_SESSION['ingelogd'] = 11;
	}else {
		$_SESSION['ingelogd'] = 13;
	}
}

//header('Location: http://www.mijnhonkbal.nl/login/');
if(empty($_POST['target'])) {
	header("Location: http://localhost".str_replace("^", "&", $_GET['target']));
}else {
	header("Location: http://localhost".str_replace("^", "&", $_POST['target']));
}
?>